async function convertintent(trainingPhrasesParts, messageTexts, displayName) {
  // Imports the Dialogflow library
  const dialogflow = require("dialogflow");
  const path = require("path");

  // Instantiates the Intent Client
  const intentsClient = new dialogflow.IntentsClient({
    keyFilename: path.join(__dirname, "./GrantDialogflowNode-02f1c9fcdbb6.json")
  });

  // The path to identify the agent that owns the created intent.
  const agentPath = intentsClient.projectAgentPath(
    "grantdialogflownode-fwoaqv"
  );

  const trainingPhrases = [];

  trainingPhrasesParts.forEach(trainingPhrasesPart => {
    const part = {
      text: trainingPhrasesPart
    };

    // Here we create a new training phrase for each provided part.
    const trainingPhrase = {
      type: "EXAMPLE",
      parts: [part]
    };

    trainingPhrases.push(trainingPhrase);
  });

  const messageText = {
    text: messageTexts
  };

  const message = {
    text: messageText
  };

  const intent = {
    displayName: displayName,
    trainingPhrases: trainingPhrases,
    messages: [message]
  };

  const createIntentRequest = {
    parent: agentPath,
    intent: intent
  };

  // Create the intent
  const responses = await intentsClient.createIntent(createIntentRequest);
  console.log(`Intent ${responses[0].name} created`);
}

module.exports = convertintent;
